import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/1 13:14
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {2, 3, 3, 2, 2};
        solution.countDistinct(nums, 2, 2);
    }
    public int countDistinct(int[] nums, int k, int p) {
        Set<Arr> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            int cnt = k;
            for (int j = i; j < nums.length; j++) {
                if (nums[j] % p == 0) {
                    cnt--;
                }
                if (cnt >= 0) {
                    set.add(new Arr(Arrays.copyOfRange(nums, i, j + 1)));
                }
            }
        }
        return set.size();
    }
}

class Arr{
    int[] nums;

    public Arr(int[] a) {
        nums = a;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Arr arr = (Arr) o;
        return Arrays.equals(nums, arr.nums);
    }
    @Override
    public int hashCode() {
        int hash = 0;
        for (int a: nums) {
            hash += a;
        }
        return hash;
    }
}
